package com.agree.common;

/**
 * 
 * @author fjw
 *	封装结果
 */
public class ReturnResult {
	
	/**
	 * 是否成功
	 */
	private boolean isSuccess = true;
	
	/**
	 * 错误位置 1: 调用异常  2: AFA系统异常 9: 业务逻辑异常
	 */
	private int errorLocation = 0;
	
	/**
	 * 错误信息
	 */
	private String errorMsg = "";
	
	/**
	 * 错误码
	 */
	private String errorCode= "";
	
	/**
	 * 返回结果
	 */
	private Object result = null;
	
	
	
	public ReturnResult() {	}

	public ReturnResult(boolean isSuccess, int errorLocation, String errorMsg,
			String errorCode, Object result) {
		this.isSuccess = isSuccess;
		this.errorLocation = errorLocation;
		this.errorMsg = errorMsg;
		this.errorCode = errorCode;
		this.result = result;
	}

	public static ReturnResult build(boolean isSuccess, int errorLocation, String errorMsg,
			String errorCode, Object result) {
        return new ReturnResult(isSuccess,errorLocation,errorMsg,
    			errorCode, result);
    }
	
	public static ReturnResult ok(Object result) {
       return new ReturnResult(true,0,"","",result);
    }

    public static ReturnResult ok() {
        return new ReturnResult(true,0,"","",null);
    }

	public boolean isSuccess() {
		return isSuccess;
	}

	public void setSuccess(boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	public int getErrorLocation() {
		return errorLocation;
	}

	public void setErrorLocation(int errorLocation) {
		this.errorLocation = errorLocation;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

	
}
